package dawnland03.model.team;

/**
 * User: Petru Obreja (obrejap@yahoo.com)
 * Date: Feb 13, 2010
 * Time: 10:30:38 PM
 */
public class Team{
    private final Integer id;
    private final String name;

    private TeamBrain teamBrain;
    private final Integer initialNumberOfTeamMembers; //if > 0, all team members will have to wait eachother until they start

    Team(Integer id, String name) {
        this.id = id;
        this.name = name;
        initialNumberOfTeamMembers = 0;
    }

    Team(Integer id, String name, Integer initialNumberOfTeamMembers) {
        this.id = id;
        this.name = name;
        this.initialNumberOfTeamMembers = initialNumberOfTeamMembers;
    }

    public Integer getId() {
        return id;
    }

    public String getName() {
        return name;
    }

    public TeamBrain getTeamBrain() {
        return teamBrain;
    }

    void setTeamBrain(TeamBrain teamBrain) {
        this.teamBrain = teamBrain;
    }

    Integer getInitialNumberOfTeamMembers() {
        return initialNumberOfTeamMembers;
    }

    public void signalTeamMemberIsReady() {
        teamBrain.signalTeamMemberIsReady();
    }

    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        Team team = (Team) o;

        if (!id.equals(team.id)) return false;

        return true;
    }

    public int hashCode() {
        return id.hashCode();
    }

    public String toString() {
        StringBuilder stringBuilder = new StringBuilder();
        stringBuilder.append("T(").append(name).append(")");
        return stringBuilder.toString();
    }
}
